package com.data2wisdom.comm.extend.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

public class DateToStringConverter implements Converter<Date, String> {

	@Override
	public String convert(Date source) {
		if (source == null) {
			return null;
		}
		try {
			SimpleDateFormat formatter = new SimpleDateFormat(
					"yyyy-MM-dd HH:mm:ss");
			return formatter.format(source);
		} catch (Exception e) {
			throw new RuntimeException(String.format(
					"parser %s to String fail", source));
		}
	}

}
